import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { QuotationSchemeVO, QuotationSchemeForm, QuotationSchemeQuery } from '@/api/goods/quote/types';

/**
 * 查询报价方案列表
 * @param query
 * @returns {*}
 */

export const listQuotationScheme = (query?: QuotationSchemeQuery): AxiosPromise<QuotationSchemeVO[]> => {
  return request({
    url: '/order/quotationScheme/list',
    method: 'get',
    params: query
  });
};
/**
 * 查询报价方案列表
 * @param query
 * @returns {*}
 */

export const listQuotationSchemeAll = (query?: QuotationSchemeQuery): AxiosPromise<QuotationSchemeVO[]> => {
  return request({
    url: '/order/quotationScheme/listNotPage',
    method: 'get',
    params: query
  });
};

/**
 * 查询报价方案详细
 * @param id
 */
export const getQuotationScheme = (id: string | number): AxiosPromise<QuotationSchemeVO> => {
  return request({
    url: '/order/quotationScheme/' + id,
    method: 'get'
  });
};

/**
 * 查询报价方案详细
 */
export const getQuotationSchemeAllList = (): AxiosPromise<QuotationSchemeVO> => {
  return request({
    url: '/order/quotationScheme/allList',
    method: 'get'
  });
};

/**
 * 新增报价方案
 * @param data
 */
export const addQuotationScheme = (data: QuotationSchemeForm) => {
  return request({
    url: '/order/quotationScheme',
    method: 'post',
    data: data
  });
};

/**
 * 修改报价方案
 * @param data
 */
export const updateQuotationScheme = (data: QuotationSchemeForm) => {
  return request({
    url: '/order/quotationScheme',
    method: 'put',
    data: data
  });
};

/**
 * 删除报价方案
 * @param id
 */
export const delQuotationScheme = (id: string | number | Array<string | number>) => {
  return request({
    url: '/order/quotationScheme/' + id,
    method: 'delete'
  });
};

/**
 * 状态修改
 * @param quotationSchemeId 客户端id
 * @param status 状态
 */
export function changeStatus(quotationSchemeId: string, status: string) {
  const data = {
    quotationSchemeId,
    status
  };
  return request({
    url: '/order/quotationScheme/changeStatus',
    method: 'put',
    data: data
  });
}

export default {
  list:listQuotationScheme,
  get:getQuotationScheme,
  add:addQuotationScheme,
  update:updateQuotationScheme,
  del:delQuotationScheme,
  getQuotationSchemeAllList:getQuotationSchemeAllList
}